A computing system can include an operating system (OS) executing on a hardware platform, which includes processor(s), memory, storage, input/output (IO) devices, and the like. When the OS executes directly on the hardware platform, the OS is referred to herein as a “host OS.” Computer virtualization is a technique that involves encapsulating the hardware platform of the computing system into virtual hardware platforms on which virtual machine(s) execute under control of virtualization software. A virtual machine (VM) provides virtual hardware abstractions for processor, memory, storage, and the like to a guest operating system (OS) and guest application(s) that run on the guest OS. The virtualization software provides virtual hardware platforms and virtual execution environments for the virtual machine(s).
Therefore, an OS can execute as a host OS directly on a hardware platform, or as a guest OS on a virtual hardware platform managed by virtualization software. On some hardware platforms, it is not trivial for an OS to recognize the use of virtualization software in safe manner. While some virtualization software may advertise its presence to an OS via side channels (e.g., using Advanced Configuration and Power Interface (ACPI) tables), other virtualization software may not. It is desirable for an OS to be able to detect the presence or absence of virtualization in a safe manner.